package de.jmda.core.util.fileset;

import java.io.File;
import java.io.FileFilter;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Container for a directory and a file filter.
 */
// TODO find out why namespace is not used by marshaller
@XmlRootElement(namespace = FileSet.XML_NAMESPACE)
public class DirectoryFileFilter implements Comparable<DirectoryFileFilter>
{
	@XmlElement
	private File directory;

	// TODO find out why namespace is not used by marshaller
	@XmlElement(namespace = FileSet.XML_NAMESPACE, type = FileFilterBase.class)
	private FileFilterBase fileFilter;
	
	DirectoryFileFilter(File directory, FileFilterBase fileFilter)
	{
		this();
		this.directory  = directory;
		this.fileFilter = fileFilter;
	}
		
	/**
	 * Necessary to make this class JAXB bindable.
	 */
	private DirectoryFileFilter()
	{
		super();
	}

	public File getDirectory()
	{
		return directory;
	}
	
	public FileFilter getFileFilter()
	{
		return fileFilter;
	}

	public int compareTo(DirectoryFileFilter other)
	{
		return directory.compareTo(other.getDirectory());
	}
	
	public boolean equals(DirectoryFileFilter other)
	{
		return directory.equals(other.directory);
	}
}